<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <title><spring:message code="message.lable.hospinfoStd"/></title>
     <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
    <!--[if lt IE 9]>
        <script src="${ctx}/lib/js/html5shiv.min.js"></script>
        <script src="${ctx}/lib/js/respond.min.js"></script>
    <![endif]-->
    <style type="text/css">
        div.box-body {
            margin-top:7px;
        }

    </style>
    
</head>
<body class="skin-blue sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>${(opType==0)?"医疗机构新增":"医疗机构编辑"}</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.lable.StdManage"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.lable.hospinfoStd"/></a></li>
        </ol>
    </section>
    <section class="content">
    <form id="form" class="form-horizontal" action="saveHospInfo.html" method="post">
                <input type="hidden" name="hospId" value="${hospInfo.hospId}" />
                <input type="hidden" name="opType" value="${opType}" />
                <input type="hidden" name="hospCode" value="${hospInfo.hospCode}" />
        <div class=" box box-success ">
                 <div class="box-header with-border">
                 <h3 class="box-title"><spring:message code="message.listForm.yiLiaoJiGouxinxi"/>
                    <span id="hospCode" style="color:#cccccc;font-size:15px;} " >${hospInfo.hospCode}</span>
                 </h3>
                 </div>
                <div class="box-body">
                    <div class="form-group form-group-xs">
                        <label for="hospName" class="col-sm-2 text-right"><span style="color:red">*</span>&nbsp;<spring:message code="message.listForm.yiLiaoJiGouMingCheng"/>：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="hospName" name="hospName" value="${hospInfo.hospName}" placeholder="<spring:message code="message.listForm.yiLiaoJiGouMingCheng"/>" type="text" maxlength="42" oninput="testRepByHospName()">
                        </div>
                         <label for="hospShortName" class="col-sm-3 text-right"><spring:message code="message.listForm.yiLiaoJiGouJianCheng"/>：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="hospShortName" name="hospShortName" value="${hospInfo.hospShortName}" placeholder="<spring:message code="message.listForm.yiLiaoJiGouJianCheng"/>" type="text" maxlength="21">
                        </div> 
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="orgCode" class="col-sm-2 text-right"><span style="color:red">*</span>&nbsp;<spring:message code="message.listForm.zuZhiJiGouDaiMa"/>：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="orgCode" name="orgCode" value="${hospInfo.orgCode}" placeholder="<spring:message code="message.listForm.zuZhiJiGouDaiMa"/>" type="text" maxlength="20">
                        </div>
                        <label for="area" class="col-sm-3 control-label"><span style="color:red">*</span>&nbsp;<spring:message code="message.lable.suoShuDiQu"/>：</label>
                        <input type="hidden" id="areaValue" name="area.areaid">
                        <div class="col-sm-3" >
                            <select id="area1" class="form-control" style="width:83px;display:inline-block;" ></select>
                            <select id="area2"  class="form-control" style="width:82px;display:inline-block;"></select>
                            <select id="area3" class="form-control" style="width:80px;display:inline-block;"></select>
                        </div>
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="hospClassify" class="col-sm-2 text-right"><span style="color:red">*</span>&nbsp;<spring:message code="message.listForm.yiLiaoJiGouFenLei"/>：</label>
                        <div class="col-sm-3 text-left">
                            <select class="form-control" id="hospClassify" name="hospClassify">
                                <option value=""><spring:message code="message.select.option"/></option>
                                <c:if test="${ classifyList != null }">
                                    <c:forEach items="${classifyList}" var="item">
                                        <option value="${item.dicCode}" ${hospInfo.hospClassify == item.dicCode ? "selected='selected'" : ""}>${item.dicName}</option>
                                    </c:forEach>
                                </c:if>
                            </select>
                        </div>
                        <label for="hospType" class="col-sm-3 text-right"><span style="color:red">*</span>&nbsp;<spring:message code="message.listForm.yiLiaoJiGouLeiXing"/>：</label>
                        <div class="col-sm-3 text-left">
                            <select id="hospType1" class="form-control" style="width:124px;display:inline-block;"></select>
                            <select id="hospType2" name="hosptype.hospTypeId" class="form-control" style="width:124px;display:inline-block;"></select>
                        </div>
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="hospLevelId" class="col-sm-2 text-right"><span style="color:red">*</span>&nbsp;<spring:message code="message.listForm.yiLiaoJiGouDengJi"/>：</label>
                        <div class="col-sm-3 text-left">
                            <select class="form-control" id="hospLevelId" name="hospLevelId">
                                <option value=""><spring:message code="message.select.option"/></option>
                                <c:if test="${ levelList != null }">
                                    <c:forEach items="${levelList}" var="item">
                                        <option value="${item.key}" ${hospInfo.hospLevelId == item.key ? "selected='selected'" : ""}>${item.value}</option>
                                    </c:forEach>
                                </c:if>
                            </select>
                        </div>
                        <label for="hospPhone" class="col-sm-3 text-right"><span style="color:red">*</span>&nbsp;<spring:message code="message.listForm.yiLiaoJiGouDianHua"/>：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="hospPhone" name="hospPhone" value="${hospInfo.hospPhone}" placeholder="<spring:message code="message.listForm.yiLiaoJiGouDianHua"/> <spring:message code="message.listForm.liRu"/>010—87654321" type="text" maxlength="20">
                        </div>
                    </div>
                    
                     <div class="form-group form-group-xs">
                       <label class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.listForm.yiLiaoJiGou"/><spring:message code="message.listForm.diZhi"/>：</label>
                        <div class="col-sm-9 text-left">
                            <input class=" form-control" placeholder="<spring:message code="message.listForm.yiLiaoJiGou"/><spring:message code="message.listForm.diZhi"/>" name="hospAddress" id="hospAddress" type="text" maxlength="341" value="${hospInfo.hospAddress}">
                        </div>
                    </div>
                    
                    
                    <div class="form-group form-group-xs">
                        <label for="bedNum" class="col-sm-2 text-right"><spring:message code="message.listForm.chuangWeiShu"/>：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="bedNum" name="hospInfoDetail.bedNum" value="${hospInfo.hospInfoDetail.bedNum}" placeholder="<spring:message code="message.listForm.chuangWeiShu"/>" type="text" maxlength="11">
                        </div>
                        <label for="incomPatNum" class="col-sm-3 text-right"><spring:message code="message.listForm.nianMenZhengLiangDanWei"/>：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="incomPatNum" name="hospInfoDetail.incomPatNum" value="${hospInfo.hospInfoDetail.incomPatNum}" placeholder="<spring:message code="message.listForm.nianMenZhengLiang"/>" type="text" maxlength="18">
                        </div>
                    </div>
                    
                    <div class="form-group form-group-xs">
                        <label for="staffNum" class="col-sm-2 text-right"><spring:message code="message.listForm.yuanGongShu"/>：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="staffNum" name="hospInfoDetail.staffNum" value="${hospInfo.hospInfoDetail.staffNum}" placeholder="<spring:message code="message.listForm.yuanGongShu"/>" type="text" maxlength="11">
                        </div>
                        <label for="regCap" class="col-sm-3 text-right"><spring:message code="message.listForm.zhuCheZiBenDanWei"/>：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="regCap" name="hospInfoDetail.regCap" value="${hospInfo.hospInfoDetail.regCap}" placeholder="<spring:message code="message.listForm.zhuCheZiBen"/>" type="text" maxlength="18">
                        </div>
                    </div>
                   </div> 
               
                 <div class="box-header with-border">
                 <h3 class="box-title"><spring:message code="message.listForm.faRenxinxi"/></h3>
                 </div>                
                 <div class="box-body">
                    <div class="form-group form-group-xs">
                        <label for="legalRepName" class="col-sm-2 text-right"><spring:message code="message.listForm.faRenXingMing"/>：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="legalRepName" name="hospInfoDetail.legalRepName" value="${hospInfo.hospInfoDetail.legalRepName}" placeholder="<spring:message code="message.listForm.faRenXingMing"/>" type="text" maxlength="10">
                        </div>
                        <label for="legalRepIdnum" class="col-sm-3 text-right"><spring:message code="message.listForm.faRenShengFenZheng"/>：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="legalRepIdnum" name="hospInfoDetail.legalRepIdnum" value="${hospInfo.hospInfoDetail.legalRepIdnum}" placeholder="<spring:message code="message.listForm.faRenShengFenZheng"/> <spring:message code="message.listForm.liRu"/>53010219200508011x" type="text" maxlength="20">
                        </div>
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="legalRepTelephone" class="col-sm-2 text-right"><spring:message code="message.listForm.faRenDianHua"/>：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="legalRepTelephone" name="hospInfoDetail.legalRepTelephone" value="${hospInfo.hospInfoDetail.legalRepTelephone}" placeholder="<spring:message code="message.listForm.faRenDianHua"/> <spring:message code="message.listForm.liRu"/>010—87654321" type="text" maxlength="15">
                        </div>
                        <label for="legalRepHandphone" class="col-sm-3 text-right"><spring:message code="message.listForm.faRenShouJi"/>：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="legalRepHandphone" name="hospInfoDetail.legalRepHandphone" value="${hospInfo.hospInfoDetail.legalRepHandphone}" placeholder="<spring:message code="message.listForm.faRenShouJi"/> <spring:message code="message.listForm.liRu"/>13907199856" type="text" maxlength="15">
                        </div>
                    </div>
                   </div>

                 <div class="box-header with-border">
                 <h3 class="box-title"><spring:message code="message.listForm.liangXiRenxinxi"/></h3>
                 </div>
                 <div class="box-body">
                    <div class="form-group form-group-xs">
                        <label for="contactName" class="col-sm-2 text-right"><spring:message code="message.listForm.liangXiRenXingMing"/>：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="contactName" name="hospInfoDetail.contactName" value="${hospInfo.hospInfoDetail.contactName}" placeholder="<spring:message code="message.listForm.liangXiRenXingMing"/>" type="text" maxlength="10">
                        </div>
                        <label for="contactIdnum" class="col-sm-3 text-right"><spring:message code="message.listForm.liangXiRenShengFenZheng"/>：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="contactIdnum" name="hospInfoDetail.contactIdnum" value="${hospInfo.hospInfoDetail.contactIdnum}" placeholder="<spring:message code="message.listForm.liangXiRenShengFenZheng"/> <spring:message code="message.listForm.liRu"/>53010219200508011x" type="text" maxlength="18">
                        </div>
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="contactPos" class="col-sm-2 text-right"><spring:message code="message.listForm.liangXiRenZhiWu"/>：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="contactPos" name="hospInfoDetail.contactPos" value="${hospInfo.hospInfoDetail.contactPos}" placeholder="<spring:message code="message.listForm.liangXiRenZhiWu"/>" type="text" maxlength="21">
                        </div>
                        <label for="contactTelephone" class="col-sm-3 text-right"><spring:message code="message.listForm.liangXiRenDianHua"/>：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="contactTelephone" name="hospInfoDetail.contactTelephone" value="${hospInfo.hospInfoDetail.contactTelephone}" placeholder="<spring:message code="message.listForm.liangXiRenDianHua"/> <spring:message code="message.listForm.liRu"/>010—87654321" type="text" maxlength="20">
                        </div>
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="contactHandphone" class="col-sm-2 text-right"><spring:message code="message.listForm.liangXiRenShouJi"/>：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="contactHandphone" name="hospInfoDetail.contactHandphone" value="${hospInfo.hospInfoDetail.contactHandphone}" placeholder="<spring:message code="message.listForm.liangXiRenShouJi"/> <spring:message code="message.listForm.liRu"/>13907199856" type="text" maxlength="20">
                        </div>
                        <label for="contactEmail" class="col-sm-3 text-right"><spring:message code="message.listForm.liangXiRenYouXiang"/>：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="contactEmail" name="hospInfoDetail.contactEmail" value="${hospInfo.hospInfoDetail.contactEmail}" placeholder="<spring:message code="message.listForm.liangXiRenYouXiang"/> <spring:message code="message.listForm.liRu"/>**@**.com" type="text" maxlength="20">
                        </div>
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="contactQQ" class="col-sm-2 text-right"><spring:message code="message.listForm.liangXiRenQQ"/>：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="contactQQ" name="hospInfoDetail.contactQQ" value="${hospInfo.hospInfoDetail.contactQQ}" placeholder="<spring:message code="message.listForm.liangXiRenQQ"/> <spring:message code="message.listForm.liRu"/>545969696" type="text" maxlength="20">
                        </div>
                        
                    </div>
                   </div> 

                 <div class="box-header with-border">
                 <h3 class="box-title"><spring:message code="message.listForm.yiLiaoJiGouZhiYeXuKeZhengXinxi"/></h3>
                 </div>
                 <div class="box-body">
                     <div class="form-group form-group-xs">
                        <label for="hospLiceNo" class="col-sm-2 text-right"><span style="color:red">*</span>&nbsp;<spring:message code="message.listForm.XuKeZhengHao"/>：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="hospLiceNo" name="hospInfoDetail.hospLiceNo" value="${hospInfo.hospInfoDetail.hospLiceNo}" placeholder="<spring:message code="message.listForm.yiLiaoJiGouZhiYeXuKeZhengHao"/>" type="text" maxlength="128">
                        </div>
                        <label for="hospLiceDate" class="col-sm-3 text-right"><span style="color:red">*</span>&nbsp;<spring:message code="message.listForm.youXiaoQi"/>：</label>
                        <div class="col-sm-3"> 
                                <table style="width:100%;">
                                     <tr>
                                        <td style="width:50%">
                                             <input class="form-control" id="hospLiceStartDate" name="hospInfoDetail.hospLiceStartDate" value="${fn:substring(hospInfo.hospInfoDetail.hospLiceStartDate, 0, 10)}"  type="text" readonly="readonly"  placeholder="yyyy-MM-dd"  
                                       onFocus="var endDate=$dp.$('hospLiceEndDate');WdatePicker({maxDate:'#F{$dp.$D(\'hospLiceEndDate\')}'})"  />
                                        </td>
                                        <td>&nbsp;-&nbsp;</td>
                                        <td style="width:50%">
                                           <input class="form-control" id="hospLiceEndDate" name="hospInfoDetail.hospLiceEndDate"  value="${fn:substring(hospInfo.hospInfoDetail.hospLiceEndDate, 0, 10)}"  type="text" readonly="readonly"   placeholder="yyyy-MM-dd" 
                                      onFocus="WdatePicker({minDate:'#F{$dp.$D(\'hospLiceStartDate\')}'})"  />
                                        </td>
                                     </tr>
                                  </table>
                            </div> 
                        </div> 
                  </div> 

                 <div class="box-header with-border">
                 <h3 class="box-title"><spring:message code="message.listForm.shiYeDanWeiFaRenZhengShuXinXi"/></h3>
                 </div>
                 <div class="box-body">        
                    <div class="form-group form-group-xs">
                        <label for="enterLiceNo" class="col-sm-2 text-right"><span style="color:red">*</span>&nbsp;<spring:message code="message.listForm.zhengShuHao"/>：</label>
                        <div class="col-sm-3 text-left">
                            <input class="form-control" id="enterLiceNo" name="hospInfoDetail.enterLiceNo" value="${hospInfo.hospInfoDetail.enterLiceNo}" placeholder="<spring:message code="message.listForm.shiYeDanWeiFaRenZhengShuHao"/>" type="text" maxlength="128">
                        </div>
                        <label for="enterLiceDate" class="col-sm-3 text-right"><span style="color:red">*</span>&nbsp;<spring:message code="message.listForm.youXiaoQi"/>：</label>
                        <div class="col-sm-3"> 
                                <table style="width:100%;">
                                     <tr>
                                        <td style="width:50%">
                                             <input class="form-control" id="enterLiceStartDate" name="hospInfoDetail.enterLiceStartDate" value="${fn:substring(hospInfo.hospInfoDetail.enterLiceStartDate, 0, 10)}"  type="text" readonly="readonly"  placeholder="yyyy-MM-dd"  
                                       onFocus="var endDate=$dp.$('enterLiceEndDate');WdatePicker({maxDate:'#F{$dp.$D(\'enterLiceEndDate\')}'})"  />
                                        </td>
                                        <td>&nbsp;-&nbsp;</td>
                                        <td style="width:50%">
                                           <input class="form-control" id="enterLiceEndDate" name="hospInfoDetail.enterLiceEndDate"  value="${fn:substring(hospInfo.hospInfoDetail.enterLiceEndDate, 0, 10)}"  type="text" readonly="readonly"   placeholder="yyyy-MM-dd" 
                                      onFocus="WdatePicker({minDate:'#F{$dp.$D(\'enterLiceStartDate\')}'})"  />
                                        </td>
                                       </tr>
                                    </table>
                            </div> 
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="profile" class="col-sm-2 control-label"><spring:message code="message.listForm.jianJie"/>：</label>
                        <div class="col-sm-9">
                            <textarea class="form-control" id="profile" name="hospInfoDetail.profile" rows="3" placeholder="<spring:message code="message.listForm.jianJie"/>" maxlength="666">${hospInfo.hospInfoDetail.profile}</textarea>
                        </div>
                    </div>
                   </div>
                   
                    
                
                <div class="box-footer text-center">
                    <button type="button" class="btn btn-success btn-sm" onclick="saveHospInfo();"><spring:message code="message.button.saveSpacing"/></button>
                    <a href="${ctx }/stdHospInfo/hospInfoList.html" class="btn btn-danger btn-sm"><spring:message code="message.button.getBackSpacing"/></a>
                </div>
                </div> 
            </form>
    </section>
    
     <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    
    <script type="text/javascript">
        function testRepByHospCode(){
                var hospCode = $.trim($("#hospCode").val());
                $.post("testRepByHospCode.html", {
                    hospCode : hospCode,
                    hospId : "${hospInfo.hospId}"
                }, function(result) {
                    if (result) {
                        $.alert('<spring:message code="message.listForm.yiLiaoJiGouBianMa"/><spring:message code="message.lable.yiChunZai"/>',  'warn');
                        $("#hospCode").val("");
                    } 
                }, "json"); 
        }
        
        function testRepByHospName(){
            var hospName = $.trim($("#hospName").val());
            $.post("testRepByHospName.html", {
                hospName : hospName,
                hospId : "${hospInfo.hospId}"
            }, function(result) {
                if (result) {
                    $.alert('<spring:message code="message.listForm.yiLiaoJiGouMingCheng"/><spring:message code="message.lable.yiChunZai"/>',  'warn');
                    $("#hospName").val("");
                } 
            }, "json");
    }
        
        function saveHospInfo() {
            if (!validate()) {
                return;
            }   
            $.HN.message.confirm('<spring:message code="message.HN.alert.OkSaveYESorNO"/>', '', '').on(function (e) {
                   if (e) {
            $("#form").ajaxSubmit({
                dataType : "json",
                timeout: 10000,
                success : function(result, statusText) {
                    if (result.success) {
                        var opType = ${opType==0};
                        if(opType){
                            $.alert("为您新增一条编码为"+result.msg+"的医疗机构", "success");
                        }else {
                            $.alert("<spring:message code='message.HN.alert.baoCunCheng'/>", "success");
                        }
                        document.location = "${ctx }/stdHospInfo/hospInfoList.html";
                    } else {
                        $.alert(result.msg || "<spring:message code='message.HN.alert.baoCunBai'/>", "error");
                    }
                }
            });
                   }
                   });
        }
        
        function validate() {
            
            var phoneRegex = /^1\d{10}$|^(0\d{2,3}-?|\(0\d{2,3}\))?[1-9]\d{4,7}(-\d{1,8})?$/
        
            var hospName = $.trim($("#hospName").val());
            /* var reg =  /[,\.;\:"'!] / */
            if (hospName == null || hospName == "") {
                $.alert("<spring:message code="message.yanZheng.qingShuRu"/><spring:message code="message.listForm.yiLiaoJiGouMingCheng"/>！",  "warn");
                return false;
            }else if(hospName.length>42){
                $("#hospName").trigger("focus");
                $.alert("<spring:message code="message.listForm.yiLiaoJiGouMingCheng"/><spring:message code="message.info.zuiDaChangDu"/>42<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            }

            var hospShortName = $.trim($("#hospShortName").val());
            if (hospShortName == null || hospShortName == "") {
                
            }else if(hospShortName.length>21){
                $("#hospShortName").trigger("focus");
                $.alert("<spring:message code="message.listForm.yiLiaoJiGouJianCheng"/><spring:message code="message.info.zuiDaChangDu"/>21<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            }

            var orgCode = $.trim($("#orgCode").val());
            if (orgCode == null || orgCode == "") {
                $.alert("<spring:message code="message.yanZheng.qingShuRu"/><spring:message code="message.listForm.zuZhiJiGouDaiMa"/>！",  "warn");
                return false;
            } else if (!/^[a-zA-Z0-9_]+$/.test(orgCode)) {
                $.alert("<spring:message code="message.listForm.zuZhiJiGouDaiMa"/><spring:message code="message.yanZheng.zhiNengYouZiMuShuZiZuCheng"/>",  "warn");
                return false;
            }else if(orgCode.length>20){
                $("#orgCode").trigger("focus");
                $.alert("<spring:message code="message.listForm.zuZhiJiGouDaiMa"/><spring:message code="message.info.zuiDaChangDu"/>20<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            }
            
            var area1 = $.trim($("#area1").val());
            if (area1.length==0) {
                $.alert("<spring:message code="message.select.option"/><spring:message code="message.lable.suoShuDiQu"/>！",  "warn");
                return false;
            }
            var area2 = $.trim($("#area2").val());
            var area3 = $.trim($("#area3").val());
            if((area2 != null && area2 != "") && (area3 == null || area3 == "") ){
            	$("#areaValue").val(area2);
            }
         
            if(area3 != null && area3 != "" ){
            	$("#areaValue").val(area3);
            }
            

            var hospClassify = $.trim($("#hospClassify").val());
            if (hospClassify == null || hospClassify == "") {
                $.alert("<spring:message code="message.select.option"/><spring:message code="message.listForm.yiLiaoJiGouFenLei"/>！",  "warn");
                return false;
            }

             var hospType = $.trim($("#hospType1").val());
            if (hospType == null || hospType == "") {
                $.alert("<spring:message code="message.select.option"/><spring:message code="message.listForm.yiLiaoJiGouLeiXing"/>！",  "warn");
                return false;
            } 

            var hospLevelId = $.trim($("#hospLevelId").val());
            if (hospLevelId == null || hospLevelId == "") {
                $.alert("<spring:message code="message.select.option"/><spring:message code="message.listForm.yiLiaoJiGouDengJi"/>！",  "warn");
                return false;
            }

            var hospPhone = $.trim($("#hospPhone").val());
            if (hospPhone == null || hospPhone == "") {
                $.alert("<spring:message code="message.yanZheng.qingShuRu"/><spring:message code="message.listForm.yiLiaoJiGouDianHua"/>！",  "warn");
                return false;
            } else if (!phoneRegex.test(hospPhone)) {
                $.alert("<spring:message code="message.listForm.yiLiaoJiGou"/><spring:message code="message.lable.telephoneFormatError"/>",  "warn");
                return false;
            }else if(hospPhone.length>20){
                $("#hospPhone").trigger("focus");
                $.alert("<spring:message code="message.listForm.yiLiaoJiGouDianHua"/><spring:message code="message.info.zuiDaChangDu"/>20<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            }
            
            
            var hospAddress = $.trim($("#hospAddress").val());
            if (hospAddress == null || hospAddress == "") {
                $.alert("<spring:message code="message.yanZheng.qingShuRu"/><spring:message code="message.listForm.yiLiaoJiGou"/><spring:message code="message.listForm.diZhi"/>！", "warn");
                return false;
            }else if(hospAddress.length>341){
                    $("#hospAddress").trigger("focus");
                    $.alert("<spring:message code="message.listForm.yiLiaoJiGou"/><spring:message code="message.listForm.diZhi"/><spring:message code="message.info.zuiDaChangDu"/>341<spring:message code="message.info.geZiFu"/>！", "warn");
                    return false;;
                }
            $("#hospAddress").val(hospAddress);
            
            

            var bedNum = $.trim($("#bedNum").val());
            if (bedNum == null || bedNum == "") {
                
            } else if (!/^\d+$/.test(bedNum)) {
                $.alert("<spring:message code="message.listForm.chuangWeiShu"/><spring:message code="message.lable.daYuLingDeZhengShu"/>",  "warn");
                return false;
            }else if(bedNum.length>11){
                $("#bedNum").trigger("focus");
                $.alert("<spring:message code="message.listForm.chuangWeiShu"/><spring:message code="message.info.zuiDaChangDu"/>11<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            }

            var incomPatNum = $.trim($("#incomPatNum").val());
            if (incomPatNum == null || incomPatNum == "") {
                
            } else if (isNaN(incomPatNum) || incomPatNum < 0) {
                $.alert("<spring:message code="message.listForm.nianMenZhengLiang"/><spring:message code="message.lable.daYuLingDeShu"/>",  "warn");
                return false;
            }else if(incomPatNum.length>18){
                $("#incomPatNum").trigger("focus");
                $.alert("<spring:message code="message.listForm.nianMenZhengLiang"/><spring:message code="message.info.zuiDaChangDu"/>18<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            }
            var index = incomPatNum.lastIndexOf(".");
            if (index > 0 && incomPatNum.substr(index).length > 3) {
                $.alert("<spring:message code="message.listForm.nianMenZhengLiang"/><spring:message code="message.lable.xiaoShuDianLiangWei"/>",  "warn");
                return false;
            }

            var staffNum = $.trim($("#staffNum").val());
            if (staffNum == null || staffNum == "") {
                
            } else if (!/^\d+$/.test(staffNum)) {
                $.alert("<spring:message code="message.listForm.yuanGongShu"/><spring:message code="message.lable.daYuLingDeZhengShu"/>",  "warn");
                return false;
            }else if(staffNum.length>11){
                $("#staffNum").trigger("focus");
                $.alert("<spring:message code="message.listForm.yuanGongShu"/><spring:message code="message.info.zuiDaChangDu"/>11<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            }

            var regCap = $.trim($("#regCap").val());
            if (regCap == null || regCap == "") {
                
            } else if (isNaN(regCap) || regCap < 0 ) {
                $.alert("<spring:message code="message.listForm.zhuCheZiBen"/><spring:message code="message.lable.daYuLingDeShu"/>",  "warn");
                return false;
            }else if(regCap.length>18){
                $("#regCap").trigger("focus");
                $.alert("<spring:message code="message.listForm.zhuCheZiBen"/><spring:message code="message.info.zuiDaChangDu"/>18<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            } 
            var index = regCap.lastIndexOf(".");
            if (index > 0 && regCap.substr(index).length > 3) {
                $.alert("<spring:message code="message.listForm.zhuCheZiBen"/><spring:message code="message.lable.daYuLingDeShu"/>",  "warn");
                return false;
            }

            var legalRepName = $.trim($("#legalRepName").val());
            if (legalRepName == null || legalRepName == "") {
                
            }else if(legalRepName.length>20){
                $("#legalRepName").trigger("focus");
                $.alert("<spring:message code="message.listForm.faRenXingMing"/><spring:message code="message.info.zuiDaChangDu"/>20<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            } 

            var legalRepIdnum = $.trim($("#legalRepIdnum").val());
            if (legalRepIdnum == null || legalRepIdnum == "") {
                
            } else if (!/^\d+[a-zA-Z0-9]$/.test(legalRepIdnum)) {
                $.alert("<spring:message code="message.listForm.faRenShengFenZheng"/><spring:message code="message.lable.FormatError"/>",  "warn");
                return false;
            }else if(legalRepIdnum.length>18){
                $("#legalRepIdnum").trigger("focus");
                $.alert("<spring:message code="message.listForm.faRenShengFenZheng"/><spring:message code="message.info.zuiDaChangDu"/>18<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            } 

            var legalRepTelephone = $.trim($("#legalRepTelephone").val());
            if (legalRepTelephone == null || legalRepTelephone == "") {
                
            } else if (!phoneRegex.test(legalRepTelephone)) {
                $.alert("<spring:message code="message.listForm.faRen"/><spring:message code="message.lable.telephoneFormatError"/>",  "warn");
                return false;
            }else if(legalRepTelephone.length>20){
                $("#legalRepTelephone").trigger("focus");
                $.alert("<spring:message code="message.listForm.faRenDianHua"/><spring:message code="message.info.zuiDaChangDu"/>20<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            } 

            var legalRepHandphone = $.trim($("#legalRepHandphone").val());
            if (legalRepHandphone == null || legalRepHandphone == "") {
                
            } else if (!phoneRegex.test(legalRepHandphone)) {
                $.alert("<spring:message code="message.listForm.faRen"/><spring:message code="message.lable.mobilephoneFormatError"/>",  "warn");
                return false;
            }else if(legalRepHandphone.length>20){
                $("#legalRepHandphone").trigger("focus");
                $.alert("<spring:message code="message.listForm.faRenShouJi"/><spring:message code="message.info.zuiDaChangDu"/>20<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            } 

            var contactName = $.trim($("#contactName").val());
            if (contactName == null || contactName == "") {
                
            }else if(contactName.length>20){
                $("#contactName").trigger("focus");
                $.alert("<spring:message code="message.listForm.liangXiRenXingMing"/><spring:message code="message.info.zuiDaChangDu"/>20<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            } 

            var contactIdnum = $.trim($("#contactIdnum").val());
            if (contactIdnum == null || contactIdnum == "") {
                
            } else if (!/^\d+[a-zA-Z0-9]$/.test(contactIdnum)) {
                $.alert("<spring:message code="message.listForm.liangXiRenShengFenZheng"/><spring:message code="message.lable.FormatError"/>",  "warn");
                return false;
            }else if(contactIdnum.length>18){
                $("#contactIdnum").trigger("focus");
                $.alert("<spring:message code="message.listForm.liangXiRenShengFenZheng"/><spring:message code="message.info.zuiDaChangDu"/>18<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            } 


            var contactPos = $.trim($("#contactPos").val());
            if (contactPos == null || contactPos == "") {
                
            }else if(contactPos.length>21){
                $("#contactPos").trigger("focus");
                $.alert("<spring:message code="message.listForm.liangXiRenZhiWu"/><spring:message code="message.info.zuiDaChangDu"/>21<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            } 


            var contactTelephone = $.trim($("#contactTelephone").val());
            if (contactTelephone == null || contactTelephone == "") {
                
            } else if (!phoneRegex.test(contactTelephone)) {
                $.alert("<spring:message code="message.listForm.lianXiRen"/><spring:message code="message.lable.telephoneFormatError"/>",  "warn");
                return false;
            }else if(contactTelephone.length>20){
                $("#contactTelephone").trigger("focus");
                $.alert("<spring:message code="message.listForm.liangXiRenDianHua"/><spring:message code="message.info.zuiDaChangDu"/>20<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            } 

            var contactHandphone = $.trim($("#contactHandphone").val());
            if (contactHandphone == null || contactHandphone == "") {
                
            } else if (!phoneRegex.test(contactHandphone)) {
                $.alert("<spring:message code="message.listForm.lianXiRen"/><spring:message code="message.lable.mobilephoneFormatError"/>",  "warn");
                return false;
            }else if(contactHandphone.length>20){
                $("#contactHandphone").trigger("focus");
                $.alert("<spring:message code="message.listForm.liangXiRenShouJi"/><spring:message code="message.info.zuiDaChangDu"/>20<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            } 

            var contactEmail = $.trim($("#contactEmail").val());
            if (contactEmail == null || contactEmail == "") {
                
            } else if (!/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(contactEmail)) {
                $.alert("<spring:message code="message.listForm.liangXiRenYouXiang"/><spring:message code="message.lable.FormatError"/>",  "warn");
                return false;
            }else if(contactEmail.length>20){
                $("#contactEmail").trigger("focus");
                $.alert("<spring:message code="message.listForm.liangXiRenYouXiang"/><spring:message code="message.info.zuiDaChangDu"/>20<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            } 
            
            var contactQQ = $.trim($("#contactQQ").val());
            if (contactQQ == null || contactQQ == "") {
                
            } else if (isNaN(contactQQ) || contactQQ < 0 ) {
                $.alert("<spring:message code="message.listForm.liangXiRenQQ"/><spring:message code="message.lable.daYuLingDeShu"/>",  "warn");
                return false;
            }else if(contactQQ.length>20){
                $("#contactQQ").trigger("focus");
                $.alert("<spring:message code="message.listForm.liangXiRenQQ"/><spring:message code="message.info.zuiDaChangDu"/>20<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            } 
            
            var profile = $.trim($("#profile").val());
            if (profile == null || profile == "") {
                
            }else if(profile.length>666){
                $("#profile").trigger("focus");
                $.alert("<spring:message code="message.listForm.jianJie"/><spring:message code="message.info.zuiDaChangDu"/>666<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            } 

            var hospLiceNo = $.trim($("#hospLiceNo").val());
            if (hospLiceNo == null || hospLiceNo == "") {
                $.alert("<spring:message code="message.yanZheng.qingShuRu"/><spring:message code="message.listForm.yiLiaoJiGouZhiYeXuKeZhengHao"/>",  "warn");
                return false;
            } else if (!/^[a-zA-Z0-9_]+$/.test(hospLiceNo)) {
                $.alert("<spring:message code="message.listForm.yiLiaoJiGouZhiYeXuKeZhengHao"/><spring:message code="message.yanZheng.zhiNengYouZiMuShuZiZuCheng"/>",  "warn");
                return false;
            }else if(hospLiceNo.length>42){
                $("#hospLiceNo").trigger("focus");
                $.alert("<spring:message code="message.listForm.yiLiaoJiGouZhiYeXuKeZhengHao"/><spring:message code="message.info.zuiDaChangDu"/>42<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            } 
            
            var hospLiceStartDate = $.trim($("#hospLiceStartDate").val());
            if (hospLiceStartDate == null || hospLiceStartDate == "") {
                $.alert("<spring:message code="message.select.option"/><spring:message code="message.listForm.yiLiaoJiGou"/><spring:message code="message.listForm.ZhiYeXuKeZhengStart"/>",  "warn");
                return false;
            }
            
            var hospLiceEndDate = $.trim($("#hospLiceEndDate").val());
            if (hospLiceEndDate == null || hospLiceEndDate == "") {
                $.alert("<spring:message code="message.select.option"/><spring:message code="message.listForm.yiLiaoJiGou"/><spring:message code="message.listForm.ZhiYeXuKeZhengEnd"/>",  "warn");
                return false;
            }

            var enterLiceNo = $.trim($("#enterLiceNo").val());
            if (enterLiceNo == null || enterLiceNo == "") {
                $.alert("<spring:message code="message.yanZheng.qingShuRu"/><spring:message code="message.listForm.shiYeDanWeiFaRenZhengShuHao"/>",  "warn");
                return false;
            } else if (!/^[a-zA-Z0-9_]+$/.test(enterLiceNo)) {
                $.alert("<spring:message code="message.listForm.shiYeDanWeiFaRenZhengShuHao"/><spring:message code="message.yanZheng.zhiNengYouZiMuShuZiZuCheng"/>",  "warn");
                return false;
            }else if(enterLiceNo.length>42){
                $("#hospLienterLiceNoceNo").trigger("focus");
                $.alert("<spring:message code="message.listForm.shiYeDanWeiFaRenZhengShuHao"/><spring:message code="message.info.zuiDaChangDu"/>42<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            } 


            
            if(hospLiceStartDate>hospLiceEndDate){
                $.alert("<spring:message code="message.listForm.yiLiaoJiGouZhiYeXuKeZhengHao"/><spring:message code="message.lable.youXiaoShiJian"/>",  "warn");
                return false;
            }
            
             var enterLiceStartDate = $.trim($("#enterLiceStartDate").val());
            if (enterLiceStartDate == null || enterLiceStartDate == "") {
                $.alert("<spring:message code="message.select.option"/><spring:message code="message.listForm.shiYeDanWeiFaRenZhengShuStart"/>",  "warn");
                return false;
            }
            
            var enterLiceEndDate = $.trim($("#enterLiceEndDate").val());
            if (enterLiceEndDate == null || enterLiceEndDate == "") {
                $.alert("<spring:message code="message.select.option"/><spring:message code="message.listForm.shiYeDanWeiFaRenZhengShuEnd"/>",  "warn");
                return false;
            }
            if(enterLiceStartDate>enterLiceEndDate){
                $.alert("<spring:message code="message.listForm.shiYeDanWeiFaRenZhengShuHao"/><spring:message code="message.lable.youXiaoShiJian"/>",  "warn");
                return false;
            }
            return true;
        }
         
        $(document).ready(function() {
        	var country ='000000';
        	var province = "${hospInfo.area.father.father.areaid}";
        	var city = "${hospInfo.area.father.areaid}";
        	var county ="${hospInfo.area.areaid}";
        	
        	
        	if("${areaId}"){
        		province="${areaId}";
        	}else{
        		if("${hospInfo.area.father.areaid}"==country){
            		province="${hospInfo.area.areaid}";
            		city='';
            		county='';
            	}else if("${hospInfo.area.father.father.areaid}"==country){
            		province="${hospInfo.area.father.areaid}";
            		city="${hospInfo.area.areaid}";
            		county='';
            	}
        	}
            $("#area1").HNSelect({
                url: "${ctx}/selectController/getQYArea.html", 
                data: { ID: '000000' }, 
                defaultselect: province,
                defaultText: "<option value=''><spring:message code="message.select.option"/></option>",
                func: function () {
                    $("#area2").HNSelect({
                        parent_selector: "#area1", 
                        url: "${ctx}/selectController/getQYArea.html", 
                        dataid: "ID", 
                        defaultselect: city,
                        defaultText: "<option value=''><spring:message code="message.select.option"/></option>",
                        func: function () {
                            $("#area3").HNSelect({
                                parent_selector: "#area2", 
                                url: "${ctx}/selectController/getQYArea.html", 
                                dataid: "ID", 
                                defaultselect: county,
                                defaultText: "<option value=''><spring:message code="message.select.option"/></option>",
                                func:function(){
                                    if($("#area1").children("option:selected").text()==""){
                                        $("#area1").val("");
                                    } 
                                    if($("#area2").children("option:selected").text()==""){
                                        $("#area2").val("");
                                    }
                                    if($("#area3").children("option:selected").text()==""){
                                        $("#area3").val("");
                                    } 
                                  }
                            });
                        }
                    });
                }
            });
            $("#hospType1").HNSelect({
                url: "${ctx}/selectController/getQYHospType.html", 
                data: { ID: '' }, 
                defaultText: "<option value=''><spring:message code="message.select.option"/></option>",
                defaultselect: "${hospInfo.hosptype.fatherType.hospTypeId}",
                func: function () {
                    $("#hospType2").HNSelect({
                        parent_selector: "#hospType1", 
                        url: "${ctx}/selectController/getQYHospType.html", 
                        dataid: "ID", 
                        defaultText: "<option value=''><spring:message code="message.select.option"/></option>",
                        defaultselect: "${hospInfo.hosptype.hospTypeId}"
                    });
                }
            });
        });
    </script>
    
</body>
</html>
